libname in 'h:\local_c\bfeed3';


**for REStat paper, "Breastfeeding and Children's Early Cognitive Outcomes", 1989 natality statistics;

data x;
set in.nat1989;
drop csex hisp bwt momed mstatus border regres res for hrace race;

cfem = .;
if csex = 1 then cfem = 0;
if csex = 2 then cfem = 1;

*this is based on a joint ethnicity race question they have recoded;
mhisp = .;
if (hrace ge 1 and hrace le 5) then mhisp = 1;
if (hrace ge 6 and hrace le 8) then mhisp = 0;

mnhblack = .;
if (hrace ge 1 and hrace le 6) then mnhblack = 0;
if hrace = 7 then mnhblack = 1;
if hrace = 8 then mnhblack = 0;

mblack = .;
if race = 0 then mblack = 0;
if race = 1 then mblack = 0;
if race = 2 then mblack = 1;
if race ge 3 then mblack = 0;

lt55 = .;
if (bwt = 1 or bwt = 2) then lt55 = 1;
if bwt = 3 then lt55 = 0;

momhgc = .;
if momed ge 0 and momed le 18 then momhgc = momed;

married = .;
if mstatus = 1 then married = 1;
if mstatus = 2 then married = 0;
if mstatus = 3 then married = 0;

**just in case;
if momage ge 60 then momage = .;

*birth order;
border1 = .;
border2 = .;
if border = 1 then do;
   border1 = 1;
   border2 = 0;
end;
if border = 2 then do;
   border1 = 0;
   border2 = 1;
end;
if (border ge 3 and border le 8) then do;
   border1 = 0;
   border2 = 0;
end;

*region of residence;
regne = .;
regmw = .;
regs = .;
regw = .;
if regres = 1 then do;
regne = 1;
regmw = 0;
regs = 0;
regw = 0;
end;
if regres = 2 then do;
regne = 0;
regmw = 1;
regs = 0;
regw = 0;
end;
if regres = 3 then do;
regne = 0;
regmw = 0;
regs = 1;
regw = 0;
end;
if regres = 4 then do;
regne = 0;
regmw = 0;
regs = 0;
regw = 1;
end;

*foreign residence;
for = .;
if res = 4 then for = 1;

if for ne 1;



proc means;
run;
